package com.shujia.day14;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class Code02FileInputStream {
    public static void main(String[] args) throws IOException {

        FileInputStream fileInputStream = new FileInputStream(new File("data/e.txt"));

//        int read = fileInputStream.read();
//        System.out.println(read);  // 97 -> a
//
//        System.out.println(fileInputStream.read());
//        System.out.println(fileInputStream.read());
//        System.out.println(fileInputStream.read());  // 如果读取结束那么返回的结果为-1

        int read = fileInputStream.read();
        while (read != -1){
            System.out.println((char) read);
            read = fileInputStream.read();
        }

        // 关闭输入流
        fileInputStream.close();

        FileInputStream fileInputStream2 = new FileInputStream(new File("data/e.txt"));
        System.out.println("===========");
        int re = 0;
        while ((re = fileInputStream2.read()) != -1){
            System.out.println((char)re);
        }

        fileInputStream2.close();

    }
}
